package com.kxf.androidtestdemo.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.TextView;

import com.kxf.androidtestdemo.R;

import java.util.Set;

public class ScrollTextViewActivity extends AppCompatActivity {

    private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scroll_text_view);
        tv = findViewById(R.id.tv);
        tv.setSelected(true);

        Intent intent = getIntent();
        String scheme = intent.getScheme();
        Log.i("ScrollTextViewActivity", "onCreate scheme=" + scheme);
        Uri uri = intent.getData();
        Log.i("ScrollTextViewActivity", "onCreate uri=" + uri);
        String appId = uri.getQueryParameter("appId");
        Log.i("ScrollTextViewActivity", "onCreate appId=" + appId);
        String sign = uri.getQueryParameter("sign");
        Log.i("ScrollTextViewActivity", "onCreate sign=" + sign);

        Set<String> keys = uri.getQueryParameterNames();
        Log.i("ScrollTextViewActivity", "onCreate keys=" + keys);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.i("ScrollTextViewActivity", "onKeyDown event=" + event);
        if (keyCode == KeyEvent.KEYCODE_BACK){
            Log.i("ScrollTextViewActivity", "onKeyDown setResult event=" + event);
            setResult(RESULT_OK, new Intent());
            finish();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
